<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<link rel="stylesheet" type="text/css" href="../../../css/base.css" />
	<link id="easyuiTheme"  rel="stylesheet" type="text/css" href="../../../easy-ui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../../easy-ui/themes/icon.css">
	<script type="text/javascript" src="../../../easy-ui/jquery.min.js"></script>	
	<script type="text/javascript" src="../../../easy-ui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../easy-ui/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../../../js/base.js" ></script>
	<script type="text/javascript" src="../../../js/ajaxfileupload.js" ></script>
	<script type="text/javascript" src="../../../js/public.js" ></script>
    <style type="text/css">
    body,html,div,ul,li,span,p,input,form,label,a,img,em,dl,dt,dd,textarea,h3,table,th,td,tr{margin:0;padding:0;font-size:12px;font-family:"'微软雅黑 ', '微软雅黑'"!important;list-style:none;font-style:normal;word-break: break-all;word-wrap: break-word;}
	input[type="text"]::-ms-clear{display:none;}
	input[type="radio"],input[type="checkbox"]{cursor:pointer;vertical-align:middle;}
	.fl{float:left;}
	.fr{float:right;}
	.oh{overflow:hidden;}
	.table-gray{background: #f8f8f8;text-align: left;line-height: 20px;}
	.myTable{ padding: 30px; border: 1px solid #c9c9c9;}
	.td-span{padding-left: 15px;}
	.myTable>table{width: 100%; border-top: 1px solid #c9c9c9; border-right: 1px solid #c9c9c9;}
	.myTable>table>tbody>tr{overflow: hidden;}
	.myTable>table>tbody>tr>td{border-left: 1px solid #c9c9c9;border-bottom: 1px solid #c9c9c9;padding:10px;}
	.myTable>table>tbody>tr>td>input{height: 24px;width: 80px;}
	.myTable>table>tbody>tr>td>select{width: 100%;}
	.myTable>table>tbody>tr>td>textarea{width: 100%;}
	.td-sec{margin: 8px 8px;}
	.td-sec>span{padding-right: 8px;}
	.td-sec>span>input{width: 60px;}
	.td-a{display: block;background: #0d73b4;width: 75px;height: 24px;line-height: 24px;text-align: center;border-radius: 5px;-moz-border-radius: 5px;-ms-border-radius: 5px;-webkit-border-radius: 5px;-o-border-radius:5px;color: #fff}
	.td-third>textarea{width: 85%; height: 80px;margin-left: 0px;}
	.table-solo{overflow: hidden;text-align: center;}
	.table-solo>td{border: 1px solid #C9C9C9;padding: 5px;}
	.searchitem{display: inline-block;width: 50px;border: 1px solid #c9c9c9;margin-right: 6px; text-align: center;padding: 6px;    cursor: pointer;}
    .searchitem-on{border: 1px solid #ea0000;}
    .selectuser{display: inline-block;margin-left: 26px;width: 80px;height: 26px;text-align: center; line-height: 26px;background-color: #488fd1;color: #fff;text-decoration: none}
    .contRight{text-align: right;}
    .fileImg{position: relative;width: 150px;height: 150px;display: inline-block;font-size: 34px;text-align: center;line-height: 150px;color: #B3B3B3;border: 1px solid #E0E0E0;background-size: 100% 100%;background-repeat: no-repeat;}
    .fileIpt{position: absolute;top: 0;left: 0;width: 150px!important;height: 150px!important;opacity: 0;}
    .alertWrap{display: none;width: 100%;height: 100%;background: rgba(10,10,10,0.8);position: absolute;z-index: 101;}
    .alertWin{width: 400px;height: 150px;background: #fff;position: absolute;left: 0;top: 300px;right: 0;margin: auto;border-radius: 12px;}
    #alertId{width: 100%;height: auto;margin-top: 30px;text-align: center;font-size: 22px;color: #1e1a1b;}
    .alertBtn{ font-size: 16px;color: #fff;   width: 100px;height: 40px;background: #488fd1; text-align: center;line-height: 40px; margin: 35px auto 0;border-radius: 12px;}
    </style>
</head>
<body class="easyui-layout" data-options="fit:true" style="overflow:hidden;">
<div class="alertWrap">
		<div class="alertWin">
			<p id="alertId">asdfasdfsdf</p>
			<div class="alertBtn" onclick="windowsOff()">关闭</div>
		</div>
	</div>
<div data-options="region:'south',border:false," style="height:45px;text-align:center;">

	<table style="width:100%;margin-top:8px;" >
		<tr><td style="align:center;">
		<a href='javascript:void(-1);' onclick="baseFormSubmit();"; class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a>&nbsp;&nbsp;
		<a href='javascript:void(-1);' onclick="baseFormReset();";  class="easyui-linkbutton" data-options="iconCls:'icon-back'">重置</a>
		</td></tr>
	</table>
</div>

<div data-options="region:'center',border:true,">
<!-- the dataForm start  -->
<form  id="bankIdForm" name="bankIdForm" method="post" target="hiddenFrame" style="margin:0px;padding:0px;overflow:hidden;opacity: 0;">
	<input type="hidden" name="bankId" id="bankId" value="" />
</form>
<form  id="shopIdForm" name="shopIdForm" method="post" target="hiddenFrame" style="margin:0px;padding:0px;overflow:hidden;opacity: 0;">
	<input type="hidden" name="shopId" id="shopId" value="" />
</form>
<form id="baseForm" name="baseForm" method="post" target="hiddenFrame" style="margin:0px;padding:0px;overflow:hidden;">

	<input id="id" name="id" type="hidden" value="" /> 
	<input id="businessAccountBank" name="businessAccountBank" type="hidden" value="" /> 
	<input id="businessAccountBankBranch" name="businessAccountBankBranch" type="hidden" value="" /> 
	
<div class="myTable">
		 
	  <table cellpadding="0" cellspacing="0" style="margin-top: 10px;">
	    <tbody>
	      <tr>
	        <td class="table-gray" width="10%" >选择商场：</td>
	        <td style="width: 40%;" colspan="3"  class="data-table-input">
       			 <input class="easyui-combobox" id="shop_combobox" data-options="valueField:'id',textField:'text',editable:true," style="width:202px;"/>					        
	         </td>
	      </tr>
	      <tr>
	      	<td>法人信息</td>
	      	<td>
	      		<tr>
		      		<td class="table-gray contRight" width="10%" >法人姓名：</td>
			        <td >
		       		 	<input  name="legalName" id="legalName"  type="text"   style="width: 31%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true,validType:['CHS']" >			        
			        </td>
		        </tr>
	      		<tr>
			        <td class="table-gray contRight" width="10%" >法人身份证号：</td>
			        <td >
		       		 <input onblur="iptID(this)"  name="legalIdNo" id="legalIdNo"  type="text"  style="width: 31%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true" >			        
			        </td>
	      		</tr>
	      		<tr>
			        <td class="table-gray contRight" width="10%" >法人电话：</td>
			        <td >
		       		 <input onblur="iptNumber(this)" name="legalMobile" id="legalMobile"  type="text" maxlength="11"  style="width: 31%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true,validType:['mobileAndTel']" >			        
			        </td>
	      		</tr>
	      	</td>
	         
	      </tr>
	      <tr>
	      	<td>法人身份证</td>
	      	<td>
		      	<tr>
			        <td class="table-gray contRight" width="10%" >法人身份证正面：</td>
			        <td style="position: relative;">
			        	<div class="fileImg" id="IdCs"><span style="font-size: 34px;text-align: center;line-height: 150px;color: #B3B3B3;">+</span>
			        		<input onchange="fileChange(this,'IdCs')"  name="" id="legalIdImgP"  type="file"  style="width: 31%;" class="easyui-validatebox textbox fileIpt"  >			        
			        		<input name="legalIdImgP" class="legalIdImgOpt"  type="text" hidden="hidden" >			        
			       		</div>
		       		 </td>
		      	</tr>
		      	<tr>
			         <td class="table-gray contRight" width="10%" >法人身份证反面：</td>
			        <td style="position: relative;">
			        	<div class="fileImg" id="IdOs"><span style="font-size: 34px;text-align: center;line-height: 150px;color: #B3B3B3;">+</span>
			        		<input onchange="fileChange(this,'IdOs')"  name=" " id="legalIdImgO"  type="file" hidden style="width: 31%;" class="easyui-validatebox textbox fileIpt"  >			        
			        		<input name="legalIdImgO" class="legalIdImgOpt"   type="text" hidden="hidden"  >			        
			         	</div>
		       		 </td>
		      	</tr>
		      </tr>
		    </td>
	      <tr>
	      	<td>结算账户</td>
	      	<td>
		      	<tr>
			        <td class="table-gray contRight" width="10%" >银行名称：</td>
			      <!--   <td >
		       		 <input  name="businessAccountBank" id="businessAccountBank"  type="text"  type="text" style="width: 31%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true,validType:['CHS']" >			        
			        </td> -->
			        <td style="width: 40%;" colspan="3"  class="data-table-input">
	       			 <input class="easyui-combobox" id="bank_combobox"  data-options="valueField:'id',textField:'text',editable:true," style="width:202px;"/>					        
	         		</td>
		        </tr>
		      	<tr>
		          	<td class="table-gray contRight" width="10%" >分支行名称：</td>
			       <!--  <td >
		       		 <input  name="businessAccountBankBranch" id="businessAccountBankBranch"  type="text"  type="text" style="width: 31%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true,validType:['CHS']" >			        
			        </td> -->
			         <td style="width: 40%;" colspan="3"  class="data-table-input">
	       			 <input class="easyui-combobox" id="branch_combobox"  data-options="valueField:'id',textField:'text',editable:true," style="width:202px;"/>					        
	         		</td>
		       </tr>
		        <tr>
			        <td class="table-gray contRight" width="10%" >公司名称：</td>
			        <td >
		       		 <input  name="businessName" id="businessName"  type="text"  type="text" style="width: 31%;" class="easyui-validatebox textbox" readonly="true" data-options="required:true,novalidate:true" >			        
			        </td>
		        </tr>
		        <tr>
			        <td class="table-gray contRight" width="10%" >公司简称：</td>
			        <td >
		       		 <input  name="businessNameShort" id="businessNameShort"  type="text"  type="text" style="width: 31%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true" >			        
			        </td>
		        </tr>
		      	<tr>
			        <td class="table-gray contRight" width="10%" >银行账号：</td>
			        <td >
		       		 <input onblur="iptBankAccount(this)" name="businessAccount" id="businessAccount"  type="text"  type="text" style="width: 31%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true,validType:['number']" >			        
			        </td>
		        </tr>
		    </td>
	      </tr>
	    </tbody>
	  </table>
	</div>
</form>
<!-- the dataForm end  -->
</div>
<script type="text/javascript">
//弹窗关闭
function windowsOff(){
	$(".alertWrap").hide()
}
//ipt[number]电话验证
function iptNumber(obj){
	 var tel = $(obj).val();
	 if(tel==""){
		$(".alertWrap").show();
		$("#alertId").html("请输入电话号码！");
		return false;
	 }
	if(!/^1[34578]\d{9}$/.test(tel)){
		$(obj).val("");
		$(".alertWrap").show();
		$("#alertId").html("电话输入有误，请重填!");
		return false;
	}
}
//ipt 身份证验证
/* function iptID(obj){
	 var tel = $(obj).val();
	 if(tel==""){
		$(".alertWrap").show();
		$("#alertId").html("请输入身份证号码!");
		return false;
	 }
	if(!/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(tel)){
		$(obj).val("");
		$(".alertWrap").show();
		$("#alertId").html("身份证输入有误，请重填!");
		return false;
	}
} */

//ipt 银行卡验证
function iptBankAccount(obj){
	 var tel = $(obj).val();
	 if(tel==""){
		$(".alertWrap").show();
		$("#alertId").html("请输入银行卡号!");
		return false;
	 }
	 if(!(/^(\d{16}|\d{19})$)/.test(tel))){
		$(obj).val("");
		$(".alertWrap").show();
		$("#alertId").html("银行卡号输入有误，请重填!");
		return false;
	}
}


//ipt[file]图片上传
 function fileChange(obj,imgId,e){
 	var $file = $(obj);
    var fileObj = $file[0];
    var windowURL = window.URL || window.webkitURL;
    var dataURL;
    var $img = $("#"+imgId);
    var reader = new FileReader();
    reader.onload = (function (file) {
        return function (e) {
          $img.find(".legalIdImgOpt").val(""+this.result.split(",")[1])
          
           console.log($img.find(".legalIdImgOpt").val()); 
        };
    })(fileObj.files[0]);
    reader.readAsDataURL(fileObj.files[0]);
//  console.log(fileObj.files[0])
    if (!/\/(?:jpg|jpeg|png|gif)/i.test(fileObj.files[0].type)) {
		$(".alertWrap").show();
		$("#alertId").html("请提交正确的图片格式!");
    	return false;
    }
    if(fileObj.files[0].size>(600*1024)){
		$(".alertWrap").show();
		$("#alertId").html("图片大小超过600K!");
    	return false;
    }
    $img.find('span').html("");
    if (fileObj && fileObj.files && fileObj.files[0]) {
        dataURL = windowURL.createObjectURL(fileObj.files[0]);
        $img.css('background-image', "url("+dataURL+")");
    } else {
        dataURL = $file.val();
        var imgObj = document.getElementById(""+imgId);
        imgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
        imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").style.backgroundImage ="url("+dataURL+")";

    }
    
 }
	
	function initPage(){
		
		parent.showProgressing();
		sendRequestAjax('../../../zcshop/getAllNotAuthShop.do?responseFunction=initAdd',initAdd);
	}
	window.onload=function(){
		
		initPage();
	}
	var responseResultPage;
	function initAdd(responseResult){
	
	//	setFormDefault(responseResult);  
		responseResultPage=responseResult;
		$('#shop_combobox').combobox({
	  		data: responseResult.data,
	  		value:'',
	  		mode:"local",
	  		//width:parseInt($("#baseForm")[0].offsetWidth)+2,
	  		onSelect: function(record){
		  			document.getElementById("id").value=record.id;
		  			$("#shopId").val(record.id);
		  			sendRequestAjax('../../../zcshop/queryBusinessName.do?responseFunction=queryBusinessName',queryBusinessNameReturn,'shopIdForm');
			},
			filter: function(q, row){
				var opts = $(this).combobox('options');
				var is = row[opts.textField].indexOf(q) >= 0;
				return is;
			}
		});
		$('#bank_combobox').combobox({
	  		data: responseResult.bankList,
	  		value:'',
	  		mode:"local",
	  		//width:parseInt($("#baseForm")[0].offsetWidth)+2,
	  		onSelect: function(record){
		  			document.getElementById("businessAccountBank").value=record.id;
//		  			bankId =record.id;
		  			$("#bankId").val(record.id);
		  			sendRequestAjax('../../../zcbank/queryBranchList.do?responseFunction=queryBranchList',queryBranch,'bankIdForm');
			},
			filter: function(q, row){
				var opts = $(this).combobox('options');
				var is = row[opts.textField].indexOf(q) >= 0;
				return is;
			}
		});
		parent.closeProgressing();  
	}
	function queryBranch(responseResult){
		$('#branch_combobox').combobox({
			data: responseResult.branchList,
			value:'',
			mode:"local",
			//width:parseInt($("#baseForm")[0].offsetWidth)+2,
			onSelect: function(record){
					document.getElementById("businessAccountBankBranch").value=record.id;
			},
			filter: function(q, row){
				var opts = $(this).combobox('options');
				var is = row[opts.textField].indexOf(q) >= 0;
				return is;
			}
		});
		//	console.log($("#branch_combobox").find('.panel-body-noheader'))
		var i = 0;
			$("#branch_combobox>panel-body-noheader").onScroll = function(){
		//		sendRequestAjax('../../../zcbank/queryBranchList.do?responseFunction=queryBranchList',queryBranch,'bankIdForm');
				console.log(i++)
			}
	}
	
	function queryBusinessNameReturn(responseResult){
		document.getElementById("businessName").value = responseResult.data.businessName;
	} 
	
	//form表单 提交 重置 提交后响应处理 ----------------
	function baseFormSubmit(){
		
		var flag= $("#baseForm").form('enableValidation').form('validate');
		console.log(flag);
	    if(flag){
//	    	$("*[name='startTime']").val(transdate($("*[name='startTime']").val()));
	    	parent.showProgressing();
			sendRequestAjax('../../../zcshop/comfirmShopAuth.do?responseFunction=addSave',addSave);
	    }
		
	}
	function baseFormReset(){
		
		 initAdd(responseResultPage);  
		
	}
	function addSave(responseResult){
	    executeWindowCallback( {});
		
		if(responseResult.slide_msg_key==1){
			parent.parent.showSlideMsg(responseResult.slide_msg_message_key);
		}
		parent.closeProgressing();
		
		//关闭当前tab
		var currentTab =parent.parent.$('#tabs').tabs('getSelected');
        var currtab_title = currentTab.panel('options').title;
        var currtab_id = currentTab.panel('options').id;
        if(currtab_id!='index_welcome_id'){
       		 parent.parent.$('#tabs').tabs('close', currtab_title);
        }
		

		
	}
	//form表单 提交 重置 提交后响应处理结束 ------------
//easyui日期控件  时间格式转化
	function myformatter(date){
		var y = date.getFullYear();
		var m = date.getMonth()+1;
		var d = date.getDate();

		var h = date.getHours();
		var mm = date.getMinutes();
		var s = date.getSeconds();
		return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d)+' '+(h<10?('0'+h):h)+':'+(mm<10?('0'+mm):mm) +':'+(s<10?('0'+s):s) ;
	}
	function myparser(s){
		if (!s) 
			return new Date();
		var dm = s.split(' ')
		var ss = (dm[0].split('-'));
		var y = parseInt(ss[0],10);
		var m = parseInt(ss[1],10);
		var d = parseInt(ss[2],10);
		
		var hms = (dm[1].split(':'));
		var h =  parseInt(hms[0],10);
		var mm =  parseInt(hms[1],10);
		var s =  parseInt(hms[2],10);
		if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
			return new Date(y,m-1,d,h,mm ,s );
		}else{
			return new Date();
		}
	}
</script>
</body>
</html>